package main.java.model;

public class GeneralElectroValve extends ElectroValve {
    
    //static final variables to time
    private static final int TIME = 1100;
    
    /**
     * Constructor GeneralElectroValve
     */
    public GeneralElectroValve() {
        //From ElectroValve
        super();
    }
    
    /**
     * Supply the hydraulic circuit
     * @param electroValve : the electro valves
     * @param hydraulicCircuit : the hydraulic circuits
     */
    public void supply(ElectroValve [] electroValve, HydraulicCircuit [] hydraulicCircuit) {
        long t = System.currentTimeMillis();
        long end = t + TIME;
        int elementId = 0;
        
        //Timer
        while (System.currentTimeMillis() < end) { 
            elementId = 0;
            
            //For each electro valve
            for (ElectroValve eValve : electroValve) { 
                //If it has to get supplied
                if (eValve.isE()) { 
                    eValve.setPressure(eValve.getPressure() + 1);
                    //Supply
                    eValve.supply(hydraulicCircuit, elementId); 
                }
                
                elementId = elementId + 1;
            }
        }
    }
}
